/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dal;

import entities.Shift;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;

/**
 *
 * @author MinhDuc
 */
public class ShiftDA {

    Connection connect = null;

    public ShiftDA() {
        connect = ConnectDatabase.getConnection();
    }

    public Vector<Shift> getAll() {
        Vector<Shift> data = new Vector<Shift>();
        String select = "SELECT * FROM Shift";
        try {
            Statement stm = connect.createStatement();
            ResultSet rs = stm.executeQuery(select);
            while (rs.next()) {
                Shift shift = new Shift();
                shift.setShiftID(rs.getNString(1));
                shift.setShiftName(rs.getNString(2));
                shift.setTimeIn(rs.getNString(3));
                shift.setTimeOut(rs.getNString(4));
                shift.setDuration(rs.getFloat(5));

                data.add(shift);
            }
            rs.close();
            stm.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return data;
    }
}
